package org.icosagon;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.icosagon.core.items.Cost;
import org.icosagon.core.items.Item;
import org.icosagon.core.math.Equation;
import org.matheclipse.parser.client.eval.DoubleEvaluator;
import org.xml.sax.SAXException;

/**
 *
 * @author Daniel Owens
 */
public class Main {
    public static void main(String[] args) {
        Item item = new Item();
        item.setName("long sword");
        item.setDescription("This is a sword that is longer than a short sword");
        Cost cost = new Cost();
        cost.setDenomination("gold");
        cost.setAmount(120);
        item.setCost(cost);
        item.setWeight(5);

        Schema schema = null;
        try {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            schema = factory.newSchema(new File("./etc/schema/item.xsd"));
        } catch (SAXException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            JAXBContext context = JAXBContext.newInstance(Item.class);
            Marshaller marshal = context.createMarshaller();
            marshal.setSchema(schema);
            marshal.marshal(item, new File("./etc/test.xml"));
        } catch (JAXBException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}